import { takeEvery, put, call } from 'redux-saga/effects'

import { get } from '@/utils/http.js'

import actionCreater from './actionCreator'

function * loadDataAsync() {
  let res = yield call(get, {url: "/api/list"})
  yield put(actionCreater.loadDataSync(res.data.data))
}

function * loadData() {
  // 接收所有的dispatch 对应的action的请求
  yield takeEvery('loadDataSaga', loadDataAsync)
}

export default loadData